package com.wujilin.okra;

import static android.graphics.Color.parseColor;

import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import android.app.Application;
import android.content.Context;
import android.view.LayoutInflater;

import com.wujilin.okra.database.OkraDatabase;
import com.wujilin.okra.database.Sql;

public class Okra extends Application {
	public static final String PACKAGE_NAME = "com.wujilin.okra";
	
    public static final int COLOR_BRIGHTEN = parseColor("#46BF18");
    public static final int COLOR_GREY600  = parseColor("#8D8D8D");

    public static final String TAG_HOME = "home";
    public static final String TAG_CATEGORY = "category";
    public static final String TAG_ARCHIVE = "archive";
    public static final String TAG_DIALOG_OBJECTIVE_NEW = "newObjectiveDialog";
    public static final String TAG_DIALOG_OBJECTIVE_EDIT = "editObjectiveDialog";
    public static final String TAG_DIALOG_OKRA_DELETE = "deleteOkraDialog";
    public static final String TAG_DIALOG_CATEGORY_NEW = "newCategoryDialog";
    public static final String TAG_DIALOG_CATEGORY_EDIT = "editCategoryDialog";
    public static final String TAG_DIALOG_CATEGORY_DELETE = "deleteCategoryDialog";
    public static final String TAG_DIALOG_CATEGORY_CHOOSE = "chooseCategoryDialog";
    public static final String TAG_DIALOG_KEY_RESULT_NEW = "newKeyResultDialog";
	public static final String TAG_DIALOG_KEY_RESULT_EDIT = "editKeyResultDialog";
	public static final String TAG_DIALOG_KEY_RESULT_DELETE = "deleteKeyResultDialog";
    
	public static final int REQUEST_OKRA = 1;
    public static final int REQUEST_OBJECTIVE_NEW = 2;
    public static final int REQUEST_OBJECTIVE_EDIT = 3;
    public static final int REQUEST_KEY_RESULT_NEW = 4;
    public static final int REQUEST_KEY_RESULT_EDIT = 5;
    public static final int REQUEST_KEY_RESULT_DELETE = 6;
    public static final int REQUEST_CATEGORY = 7;
    public static final int REQUEST_CATEGORY_NEW = 8;
    public static final int REQUEST_CATEGORY_EDIT = 9;
    public static final int REQUEST_CATEGORY_CHOOSE = 10;
    public static final int REQUEST_CATEGORY_DELETE = 11;
    public static final int REQUEST_OKR_LIST = 12;
    public static final int REQUEST_OKR_DELETE = 13;
    public static final int REQUEST_OKR_SEARCH = 14;
    
    public static final String EXTRA_OBJECTIVE_ID = PACKAGE_NAME + ".extra.OBJECTIVE_ID";
    public static final String EXTRA_OBJECTIVE_CONTENT = PACKAGE_NAME + ".extra.OBJECTIVE_CONTENT";
    public static final String EXTRA_OBJECTIVE_TIME = PACKAGE_NAME + ".extra.OBJECTIVE_TIME";
    public static final String EXTRA_OBJECTIVE_GRADE = PACKAGE_NAME + ".extra.OBJECTIVE_GRADE";
    public static final String EXTRA_OBJECTIVE_YEAR = PACKAGE_NAME + ".extra.OBJECTIVE_YEAR";
    public static final String EXTRA_OBJECTIVE_QUARTER = PACKAGE_NAME + ".extra.OBJECTIVE_QUARTER";
    public static final String EXTRA_CATEGORY_ID = PACKAGE_NAME + ".extra.CATEGORY_ID";
    public static final String EXTRA_CATEGORY_NAME = PACKAGE_NAME + ".extra.CATEGORY_NAME";
    public static final String EXTRA_KEY_RESULT_ID = PACKAGE_NAME + ".extra.KEY_RESULT_ID";
    public static final String EXTRA_KEY_RESULT_CONTENT = PACKAGE_NAME + ".extra.KEY_RESULT_CONTENT";
    public static final String EXTRA_KEY_RESULT_GRADE = PACKAGE_NAME + ".extra.KEY_RESULT_GRADE";
    public static final String EXTRA_OKR_LIST_TITLE = PACKAGE_NAME + ".extra.OKR_LIST_TITLE";
    public static final String EXTRA_LOADER_ID = PACKAGE_NAME + ".extra.LOADER_ID";
    
    public static final DateTimeFormatter FORMATTER_DATE_TIME = DateTimeFormat.forPattern("yyyy/MM/dd HH:mm");
    
    public static final String T_OBJECTIVE = "objective";
    public static final String T_KEY_RESULT = "key_result";
    public static final String T_CATEGORY = "category";
    
    public static final String F_ID = "_id";
    public static final String F_CONTENT = "content";
    public static final String F_TIME = "time";
    public static final String F_GRADE = "grade";
    public static final String F_NAME = "name";
    public static final String F_OBJECTIVE_ID = "objective_id";
    public static final String F_CATEGORY_ID = "category_id";
    
    public static final int LOADER_OKRA_LIST = 1;
    public static final int LOADER_OKRA_LIST_BY_CATEGORY = 11;
    public static final int LOADER_OKRA_LIST_BY_YEAR = 12;
    public static final int LOADER_OKRA_LIST_BY_QUARTER = 13;
    public static final int LOADER_OKRA_LIST_BY_SEARCH = 14;
    public static final int LOADER_OBJECTIVE = 2;
    public static final int LOADER_KEY_RESULT_LIST = 3;
    public static final int LOADER_ARCHIVE_LIST = 4;
    public static final int LOADER_CATEGORY_LIST = 5;
    public static final int LOADER_CATEGORY_CHOICE = 6;
	
	@Override
	public void onCreate() {
		super.onCreate();
		OkraDatabase database = new OkraDatabase(getApplicationContext());
		Sql.setup(database);
	}
	
    public static LayoutInflater getLayoutInflater(Context context) {
        return (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE);
    }
}
